﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MxWeiXinPF.Common;
using System.Text;
using System.Web.SessionState;
using System.Data;
using Senparc.Weixin.MP.CommonAPIs;
using Senparc.Weixin.Entities;
using MxWeiXinPF.Web.bussiness.coupon;
using MxWeiXinPF.Web.bussiness;

namespace MxWeiXinPF.Web.shop
{
    /// <summary>
    /// shopmgr 的摘要说明
    /// </summary>
    public class shopmgr : IHttpHandler, IReadOnlySessionState, IRequiresSessionState
    {
        private WeiXinComm.WeiXinSendMessageComm wxSM = new WeiXinComm.WeiXinSendMessageComm();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart();
            string _action = MyCommFun.QueryString("myact");
            string openid = MyCommFun.RequestOpenid();  //得到微信用户的openid
            Dictionary<string, string> jsonDict = new Dictionary<string, string>();

            MxWeiXinPF.Model.users modelByOpenid = new MxWeiXinPF.Model.users();
            BLL.users busers = new BLL.users();
            MxWeiXinPF.BLL.wx_dt_user_BaseData data = new MxWeiXinPF.BLL.wx_dt_user_BaseData();
            MxWeiXinPF.BLL.wx_shop_cart _cart = new MxWeiXinPF.BLL.wx_shop_cart();
            if ((modelByOpenid == null) || (modelByOpenid.id == 0))
            {
                if (HttpContext.Current.Session["dt_session_user_info"] != null)
                {
                    modelByOpenid = HttpContext.Current.Session["dt_session_user_info"] as MxWeiXinPF.Model.users;
                }
                else
                {
                    modelByOpenid = busers.GetModelByOpenid(openid);
                }
            }
            int shopid = 0;
            if (MyCommFun.RequestInt("shopid") > 0)
            {
                shopid = MyCommFun.RequestInt("shopid");
            }
            else if ((modelByOpenid != null) && (modelByOpenid.id > 0))
            {
                shopid = modelByOpenid.shopid;
            }

            if (_action == "addCart")
            {
                #region 添加购物车
                try
                {
                    int wid = MyCommFun.RequestInt("wid");
                    int productid = MyCommFun.RequestInt("productid");
                    int mid = MyCommFun.RequestInt("mid");
                    string attr = MyCommFun.QueryString("attr");
                    int bc = MyCommFun.RequestInt("bc");
                    decimal num6 = (decimal)MyCommFun.RequestFloat("totprice", 0f);
                    MxWeiXinPF.Model.wx_shop_cart model = new MxWeiXinPF.Model.wx_shop_cart();
                    IList<MxWeiXinPF.Model.wx_shop_cart> list = _cart.GetModelList(string.Concat(new object[] { "productId=", productid, " and userid='", modelByOpenid.id, "' and skuId=", mid }));
                    bool flag = true;
                    if ((list != null) && (list.Count > 0))
                    {
                        flag = false;
                        model = list[0];
                    }
                    if (flag)
                    {
                        model.createDate = DateTime.Now;
                        model.openid = openid;
                        model.userid = modelByOpenid.id;
                        model.productId = productid;
                        model.productNum = bc;
                        model.skuId = mid;
                        model.skuInfo = attr;
                        model.totPrice = num6 * bc;
                        model.wid = wid;
                        if (_cart.Add(model) > 0)
                        {
                            jsonDict.Add("errCode", "0");
                        }
                        else
                        {
                            jsonDict.Add("errCode", "1");
                        }
                    }
                    else
                    {
                        model.openid = openid;
                        model.wid = wid;
                        model.skuId = mid;
                        model.skuInfo = attr;
                        model.productNum += bc;
                        
                        model.totPrice += num6 * bc;
                        if (_cart.Update(model))
                        {
                            jsonDict.Add("errCode", "0");
                        }
                        else
                        {
                            jsonDict.Add("errCode", "1");
                        }
                    }
                }
                catch (Exception)
                {
                    jsonDict.Add("errCode", "1");
                }
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion
            }
            else if (_action == "pcount")
            {
                #region 购物车商品数量
                jsonDict = new Dictionary<string, string>();
                int wid = MyCommFun.RequestInt("wid");
                int count = cartBll.GetRecordCount("wid=" + wid + " and openid='" + openid + "'");
                jsonDict.Add("data", count.ToString());
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion

            }
            else if (_action == "remove")
            {
                #region 移除购物车商品
                jsonDict = new Dictionary<string, string>();
                int cartId = MyCommFun.RequestInt("id");
                cartBll.Delete(cartId);
                jsonDict.Add("errCode", "false");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion
            }
            else if (_action == "modifyNum")
            {
                #region 修改购物车商品数量
                jsonDict = new Dictionary<string, string>();
                int cartId = MyCommFun.RequestInt("ic");
                int newNum = MyCommFun.RequestInt("bc");
                cartBll.UpdateNum(cartId, newNum);
                jsonDict.Add("errCode", "false");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion

            }
            else if (_action == "getCity")
            {
                #region 选择省份，改变城市列表
                int privice = MyCommFun.RequestInt("pvid");
                BLL.pre_common_district areaBll = new BLL.pre_common_district();
                IList<Model.pre_common_district> disList = areaBll.GetModelList("upid=" + privice + " and level=2");
                Model.pre_common_district dis;
                StringBuilder jsonStr = new StringBuilder("{\"errCode\":0,\"retCode\":0,\"msgType\":0,\"errMsg\":\"\",\"data\":[");
                for (int i = 0; i < disList.Count; i++)
                {
                    dis = new Model.pre_common_district();
                    if (i != disList.Count - 1)
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"},");
                    }
                    else
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"}");
                    }
                }
                jsonStr.Append("]}");
                context.Response.Write(jsonStr);
                #endregion

            }
            else if (_action == "getArea")
            {
                #region 选择城市，改变区域列表
                int ctid = MyCommFun.RequestInt("ctid");
                BLL.pre_common_district areaBll = new BLL.pre_common_district();
                IList<Model.pre_common_district> disList = areaBll.GetModelList("upid=" + ctid + " and level=3");
                Model.pre_common_district dis;
                StringBuilder jsonStr = new StringBuilder("{\"errCode\":0,\"retCode\":0,\"msgType\":0,\"errMsg\":\"\",\"data\":[");
                for (int i = 0; i < disList.Count; i++)
                {
                    dis = new Model.pre_common_district();
                    if (i != disList.Count - 1)
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"},");
                    }
                    else
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"}");
                    }
                }
                jsonStr.Append("]}");
                context.Response.Write(jsonStr);
                #endregion

            }
            else if (_action == "order_save")
            {
                #region 保存订单信息
                //获得传参信息
                int wid = MyCommFun.RequestInt("wid");

                int payment_id = MyCommFun.RequestInt("pc");//支付方式：1货到付款；3微支付
                int express_id = MyCommFun.RequestInt("mtype");//物流方式
                int couponuse = MyCommFun.RequestInt("couponuse"); //是否使用优惠券
                int couponid = MyCommFun.RequestInt("couponid"); //优惠券ID

                // string orderStrList = MyCommFun.QueryString("orderStrList");

                //检查物流方式
                if (express_id == 0)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"对不起，请选择配送方式！\"}");
                    return;
                }
                BLL.wx_shop_user_addr uAddrBll = new BLL.wx_shop_user_addr();
                IList<Model.wx_shop_user_addr> uaddrList = uAddrBll.GetOpenidAddrName(openid, wid);
                if (uaddrList == null || uaddrList.Count <= 0 || uaddrList[0].id <= 0)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"收货地址不存在，无法结算！\"}");
                    return;
                }


                //检查购物车商品
                IList<Model.cartProduct> cartList = cartBll.GetCartList(openid, wid);
                if (cartList == null || cartList.Count == 0)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"对不起，购物车为空，无法结算！\"}");
                    return;
                }
                //统计购物车
                decimal payable_amount = cartList.Sum(c => c.totPrice);
                //物流费用
                Model.express expModel = null;
                List<Model.express> expModels = GlobalCacheHelper.Get<List<Model.express>>("express_models");
                if (expModels != null)
                {
                    foreach (var item in expModels)
                    {
                        if (item.id == express_id)
                        {
                            expModel = item;
                            break;
                        }
                    }
                }
                if (expModel == null)
                {
                    BLL.express expressBll = new BLL.express();
                    expModel = expressBll.GetModel(express_id);
                }
                //支付方式
                Model.payment payModel = GlobalCacheHelper.Get<Model.payment>("pay_models");
                if (payModel == null || payModel.pTypeId != payment_id)
                {
                    BLL.payment pbll = new BLL.payment();
                    payModel = pbll.GetModelBypTypeId(payment_id);
                }

                //保存订单=======================================================================
                Model.orders model = new Model.orders();
                model.order_no = "b" + Utils.GetOrderNumber(); //订单号B开头为商品订单

                model.wid = wid;
                model.openid = openid;
                model.modelName = "微商城";
                model.modelCode = "shop";
                model.modelActionName = "";
                model.modelActionId = 0;
                model.user_id = modelByOpenid.id;
                model.user_name = "";
                model.shopid = shopid;
                model.payment_id = payment_id;
                model.express_id = express_id;
                model.accept_name = uaddrList[0].contractPerson;
                model.post_code = "";
                model.telphone = uaddrList[0].tel;
                model.mobile = uaddrList[0].tel;
                model.area = uaddrList[0].province;
                model.city = uaddrList[0].city;
                model.district = uaddrList[0].area;
                model.address = uaddrList[0].province + " " + uaddrList[0].city + " " + uaddrList[0].area + " " + uaddrList[0].addrDetail;
                model.message = "";
                model.payable_amount = payable_amount;//应付商品总金额
                model.real_amount = payable_amount;//实际商品总金额，
                model.status = 1;
                model.express_status = 1;
                model.express_fee = expModel.express_fee; //物流费用

                if (payment_id == 1)
                {  //货到付款，需要确认订单
                    model.payment_status = 1; //标记未付款
                    model.express_status = 1;
                    model.express_fee = expModel.express_fee;
                }
                else
                {//先款后货
                    model.payment_status = 1; //标记未付款
                    model.express_status = 1;
                    model.express_fee = expModel.express_fee;
                }
                bool quicklyFH = false;
                //如果是先款后货的话
                if (payment_id == 3)
                {
                    if (payModel.poundage_type == 1) //百分比
                    {
                        model.payment_fee = model.real_amount * payModel.poundage_amount / 100;
                    }
                    else //固定金额
                    {
                        model.payment_fee = payModel.poundage_amount;
                    }
                    Model.wx_payment_wxpay wxpay = GlobalCacheHelper.Get<Model.wx_payment_wxpay>("wx_pay");
                    if (wxpay == null)
                    {
                        BLL.wx_payment_wxpay wxBll = new BLL.wx_payment_wxpay();
                        wxpay = wxBll.GetModelByWid(wid);
                    }
                    quicklyFH = wxpay.quicklyFH;

                }
                if (quicklyFH)
                {
                    model.express_status = 0;
                }
                Model.wx_shop_setting msetting = GlobalCacheHelper.Get<Model.wx_shop_setting>("yunfei");
               // if (msetting == null)
               // {
                    msetting = new BLL.wx_shop_setting().GetModel(5);
                //}
                
                decimal yunfei = 0.0m;
                if (msetting != null)
                {
                    yunfei = (decimal)msetting.extInt;
                }

                model.order_amount = (model.real_amount + model.express_fee) + model.payment_fee;//订单总金额=实付商品金额+运费+支付手续费
               if (model.real_amount > yunfei)
               {
                   model.order_amount -= model.express_fee;
                   model.dealoff_fee = model.express_fee;
               }
               model.transfer_fee = model.real_amount;
                model.rate_amount = cartList.Sum<Model.cartProduct>((Func<Model.cartProduct, decimal>)(c => c.RatePrice)); //积分
                //购物积分,可为负数
                model.point = 0;
                model.add_time = DateTime.Now;
                //商品详细列表
                List<Model.order_goods> gls = new List<Model.order_goods>();
                foreach (Model.cartProduct item in cartList)
                {
                    gls.Add(new Model.order_goods { 
                        goods_id = item.productId, 
                        goods_title = item.productName, 
                        market_price = item.markertprice,
                        sale_price = item.saleprice, 
                        cost_price = item.costprice,
                        quantity = item.productNum,
                        point = 0,
                        shopid = item.shopid
                    });
                }
                model.order_goods = gls;
                int result = new BLL.orders().Add(model);

                if (result < 1)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"订单保存过程中发生错误，请重新提交！\"}");
                    return;
                }
                model.id = result;
                #region 计算优惠券
                if (couponuse == 1 && couponid > 0)
                {
                    Model.wx_shop_coupon mc = new BLL.wx_shop_coupon().GetModel(couponid);
                    if (mc != null)
                    {
                        bool canusecoupon = false;
                        if (mc.enough == 0)
                        {
                            canusecoupon = true;
                        }
                        else
                        {
                            if (mc.enough <= model.real_amount)
                            {
                                canusecoupon = true;
                            }
                        }
                        if (mc != null && mc.status == 1 && mc.timeend >= DateTime.Now && canusecoupon)
                        {
                            List<Model.wx_shop_coupon_data> musercoupons = new BLL.wx_shop_coupon_data().GetModelList(string.Format("couponid = {0} and status = 0 ", mc.id));
                            if (musercoupons != null && musercoupons.Count > 0)
                            {
                                Model.wx_shop_coupon_data mcd = musercoupons[0];
                                decimal tempmoney = model.real_amount - mc.money;
                                if (tempmoney < 0)
                                {
                                    tempmoney = 0;
                                }
                                
                                model.transfer_fee = tempmoney; //用了优惠券的话就直接用实际金额减去优惠金额加上支付手续费
                                if (tempmoney > yunfei)
                                {
                                    tempmoney -= model.express_fee; //减去运费
                                    model.dealoff_fee = mc.money + model.express_fee;
                                }
                                else
                                {
                                    tempmoney += model.express_fee;//加上运费
                                    model.dealoff_fee = mc.money;
                                }
                                tempmoney += model.payment_fee;
                                model.order_amount = tempmoney;

                                //记录消费券使用和日志
                                CouponBussiness busscoupon = new CouponBussiness();
                                if (!busscoupon.UseCoupon(mcd.id, model))
                                {
                                    context.Response.Write("{\"errCode\":3, \"msg\":\"对不起,优惠券不存在,无法结算！\"}");
                                    return;
                                }
                            }
                        }
                    }
                }
                #endregion
                //计算优惠券之后更新订单信息
                if (!new BLL.orders().Update(model))
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"订单保存过程中发生错误，请重新提交！\"}");
                    return;
                }
                //清空购物车
                cartBll.RemoveCartInfo(wid, openid);
                //订单提交后,提示用户
                SendTemplateMsg("", model, openid, shopid);
                //提交成功，返回URL  order_no
                context.Response.Write("{\"errCode\":true, \"payType\":\"" + payment_id + "\", \"order_no\":\"" + model.order_no + "\",\"orderid\":\"" + result + "\",\"wid\":\"" + wid + "\",\"openid\":\"" + openid + "\",\"payable_amount\":\"" + payable_amount + "\", \"msg\":\"恭喜您，订单已成功提交！\"}");
                return;
                #endregion
            }
            else if (_action == "order_canel")
            {
                #region  //取消订单
                int orderid = MyCommFun.RequestInt("order_id");
                BLL.orders oBll = new BLL.orders();
                oBll.UpdateField(orderid, "status=4");
                context.Response.Write("{\"errCode\":true, \"msg\":\"订单已取消！\"}");
                #endregion

            }
            else if (_action == "shouhuo")
            {
                #region  //确认收货
                int order_id = MyCommFun.RequestInt("order_id");
                MxWeiXinPF.BLL.orders orders2 = new MxWeiXinPF.BLL.orders();
                MxWeiXinPF.Model.orders orders3 = orders2.GetModel(order_id);
                if (orders3.status >= 3)
                {
                    context.Response.Write("{\"errCode\":false, \"msg\":\"此单已完成，不能再次确认收货！\"}");
                    return;
                }
                DataSet set = orders2.InsertIntoDtUserRate(order_id);
                if ((set != null) && (set.Tables.Count > 0))
                {
                    if (orders3.payment_id == 1)
                    {
                        orders2.UpdateField(order_id, "express_status=2,payment_status=2 , status=3,complete_time=getdate()");
                        this.WXSendMessage(order_id);
                    }
                    else
                    {
                        orders2.UpdateField(order_id, "express_status=2,payment_status=2 , status=3,complete_time=getdate()");
                        //确认收货发送消息

                        this.WXSendMessage(order_id);

                        //生成购药提醒
                        GenerateGouYaoTip(orders3);
                    }
                    context.Response.Write("{\"errCode\":true, \"msg\":\"确认收货成功！\"}");
                }
                else
                {
                    context.Response.Write("{\"errCode\":false, \"msg\":\"确认收货失败！\"}");
                }
                #endregion

            }
        }

        private bool SendTemplateMsg(string content, MxWeiXinPF.Model.orders model, string useropenid, int shopid)
        {
            try
            {
                Model.manager mmodel = new BLL.manager().GetModel(shopid);
                if (mmodel == null || string.IsNullOrEmpty(mmodel.shopclerkid))
                {
                    return false;
                }
                string customname = new BLL.users().GetNickName(useropenid);
                if (string.IsNullOrEmpty(customname))
                {
                    return false;
                }
                content = string.Concat("你好,你的店铺:", mmodel.real_name, "的客户:", customname, "提交了一张新订单,请查看");
                return WxMessageFunc.SendTextMessage(mmodel.shopclerkid, content);
            }
            catch (Exception ex)
            {

            }

            return false;
        }
        private void GenerateGouYaoTip(Model.orders orders3)
        {
            BLL.orders border = new BLL.orders();
            if (orders3 == null)
            {
                return;
            }
            if (orders3.order_goods == null || orders3.order_goods.Count <= 0)
            {
                return;
            }
            BLL.wx_shop_product bpro = new BLL.wx_shop_product();
            foreach (Model.order_goods item in orders3.order_goods)
            {
                Model.wx_shop_product mpro = bpro.GetModel(item.goods_id);
                if (mpro != null && mpro.issendmessage)
                {
                    int sumjiliang = mpro.sumqty * item.quantity;
                    int perday = mpro.onedayqty;
                    int day = sumjiliang / perday;
                    DateTime dt = DateTime.Now.AddDays(day);
                    dt = dt.AddDays(-2); //提前两天发购药提醒
                    int shopid = orders3.shopid;
                    DoAdd(dt, orders3, mpro.extstr2, mpro, sumjiliang, 2);
                }
            }
        }

        private bool DoAdd(DateTime dt, Model.orders order, string content, Model.wx_shop_product product, int pjl, int tqts)
        {
            bool flag = false;
            MxWeiXinPF.Model.sendmessage model = new MxWeiXinPF.Model.sendmessage();
            MxWeiXinPF.BLL.sendmessage sendmessage2 = new MxWeiXinPF.BLL.sendmessage();
            model.wid = 39;
            model.shopid = order.shopid;
            string username = "";
            if (string.IsNullOrEmpty(order.user_name))
            {
                if (!string.IsNullOrEmpty(order.openid))
                {
                    Model.users mu = new BLL.users().GetModelByOpenid(order.openid);
                    if (mu != null)
                    {
                        if (string.IsNullOrEmpty(mu.user_name))
                        {
                            username = mu.nick_name;
                        }
                        else { username = mu.user_name; }
                    }
                }
            }
            model.truename = username;
            model.mobile = order.telphone;
            model.openid = order.openid;
            model.MessageContent = content;
            model.productname = product.productName;
            model.PurchaseQty = pjl;
            model.UsedQty = product.onedayqty;
            model.PurchaseDate = DateTime.Now;
            model.SendDate = dt;
            model.SendToDate = new DateTime(1900, 1, 1);
            model.tqts = tqts;
            if (sendmessage2.AddInfo(model) > 0)
            {
                flag = true;
            }
            return flag;
        }

        public string WXSendMessage(int id)
        {
            string str11;
            BLL.orders border = new BLL.orders();
            DataSet set = border.SelectOrderInfo(id);
            if (set == null || set.Tables[0].Rows.Count <= 0)
            {
                return "";
            }
            int wid = int.Parse(set.Tables[0].Rows[0]["wid"].ToString());
            int shopid = int.Parse(set.Tables[0].Rows[0]["shopid"].ToString());
            string openid = set.Tables[0].Rows[0]["openid"].ToString();
            string str2 = set.Tables[0].Rows[0]["pwxopenid"].ToString();
            string str3 = set.Tables[0].Rows[0]["ppwxopenid"].ToString();
            decimal amount = decimal.Parse(set.Tables[0].Rows[0]["amount"].ToString());
            decimal num4 = decimal.Parse(set.Tables[0].Rows[0]["pamount"].ToString());
            decimal num5 = decimal.Parse(set.Tables[0].Rows[0]["ppamount"].ToString());
            decimal sumamount = decimal.Parse(set.Tables[0].Rows[0]["sumamount"].ToString());
            decimal num7 = decimal.Parse(set.Tables[0].Rows[0]["psumamount"].ToString());
            decimal num8 = decimal.Parse(set.Tables[0].Rows[0]["ppsumamount"].ToString());
            string str4 = set.Tables[0].Rows[0]["nick_name"].ToString();
            string str5 = set.Tables[0].Rows[0]["pnick_name"].ToString();
            string str6 = set.Tables[0].Rows[0]["ppnick_name"].ToString();
            string phone = set.Tables[0].Rows[0]["mobile"].ToString();
            string str8 = set.Tables[0].Rows[0]["pmobile"].ToString();
            string str9 = set.Tables[0].Rows[0]["ppmobile"].ToString();
            string url = string.Concat(new object[] { MyCommFun.getWebSite(), "/wxoauth.aspx?wid=", wid, "&p=6" });
            if ((openid != null) && !openid.Equals(""))
            {
                if (amount > 0M)
                {
                     this.wxSM.SendMessageShouHuo("1", openid, wid, amount, sumamount, "", "", url);
                }
                else if (amount < 0M)
                {
                     this.wxSM.SendMessageShouHuo("2", openid, wid, amount, sumamount, "", "", url);
                }
            }
            else if (((phone != null) && !phone.Equals("")) && border.isAllowSend(shopid))
            {
                str11 = string.Concat(new object[] { "尊敬的", str4, "您本次购物获得积分：", amount, "分" });
                border.SendSMSMessage(id, shopid, phone, str4, str11);
            }
            if ((str2 != null) && !str2.Equals(""))
            {
                if (num4 > 0M)
                {
                    this.wxSM.SendMessageShouHuo("1", str2, wid, num4, num7, str4, "", url);
                }
                else if (num4 < 0M)
                {
                     this.wxSM.SendMessageShouHuo("2", str2, wid, num4, num7, str4, "", url);
                }
            }
            else if (((str8 != null) && !str8.Equals("")) && border.isAllowSend(shopid))
            {
                str11 = string.Concat(new object[] { "尊敬的", str5, "您邀请的", str4, "完成交易您获得积分：", num4, "分" });
                border.SendSMSMessage(id, shopid, str8, str5, str11);
            }
            if ((str3 != null) && !str3.Equals(""))
            {
                if (num5 > 0M)
                {
                    this.wxSM.SendMessageShouHuo("1", str3, wid, num5, num8, str5, str4, url);
                }
                else if (num5 < 0M)
                {
                    this.wxSM.SendMessageShouHuo("2", str3, wid, num5, num8, str5, str4, url);
                }
            }
            else if (((str9 != null) && !str9.Equals("")) && border.isAllowSend(shopid))
            {
                str11 = string.Concat(new object[] { "您邀请的", str5, "的下级", str4, "完成交易您获得积分：", num5, "分" });
                border.SendSMSMessage(id, shopid, str9, str6, str11);
            }
            return "";
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}